package org.apogee.mil.client.main.pages.trainer.widgets;

import org.apogee.mil.client.factories.ServerServiceFactory;
import org.apogee.mil.client.main.pages.admin.forms.widgets.TraineeWidget;
import org.apogee.mil.client.main.pages.trainee.widgets.PrevTestsWidget;
import org.apogee.mil.client.utils.Session;
import org.apogee.mil.shared.User;

import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.HorizontalPanel;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;

public class ViewTraineeWidget implements IsWidget {

	private TraineeWidget trainee;
	private PrevTestsWidget prev;
	private HorizontalPanel hp = new HorizontalPanel();
	
	
	public ViewTraineeWidget() {
		trainee = new TraineeWidget(this);
		prev = new PrevTestsWidget(-1);
	}
	
	
	@Override
	public Widget asWidget() {
		User currentUser = ServerServiceFactory.getUser(Session.getSessionId());
		
		trainee.update(currentUser.getUserId());
		
		ContentPanel cp = new ContentPanel();
		cp.setHeading("Your Trainees and Their Scores");
		cp.setHeaderVisible(true);
		cp.setAutoWidth(true);
		cp.setAutoHeight(true);
		
		hp.add(trainee.asWidget());
		hp.add(prev.asWidget());
		
		cp.add(hp);
		
		return cp;
	}


	public void update(String selectedTrainee) {
		prev.update(selectedTrainee);
		
	}

}
